﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<EAILogWebSite.Models.QueryParaModels>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    EAI Log
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% using (Html.BeginForm())
       { %>
    <%: Html.ValidationSummary(true, "Query was unsuccessful. Please correct the errors and try again.")%>
    <div>
        <fieldset>
            <legend>Search criteria</legend>
            <div class="editor-label">
                <div>
                    ID
                    <%: Html.TextBoxFor(x => x.Lid, new { @style = "width:80px;" })%>
                    MsgId
                    <%: Html.TextBoxFor(x => x.MsgId, new { @style = "width:250px;" })%>
                    CorrId
                    <%: Html.TextBoxFor(x => x.CorrId, new { @style = "width:250px;" })%>
                    SenderID
                    <%: Html.DropDownListFor(x => x.SenderID, ViewData["SenderLists"] as List<SelectListItem>)%>
                    ReceiverID
                    <%: Html.DropDownListFor(x => x.ReceiverID, ViewData["ReceiverLists"] as List<SelectListItem>)%>
                    <br />
                    StartTime
                    <%: Html.TextBoxFor(x => x.StartDate, new { @style = "width:130px;" })%>
                    <%: Html.ValidationMessageFor(m => m.StartDate)%>
                    EndTime
                    <%: Html.TextBoxFor(x => x.EndDate, new { @style = "width:130px;" })%>
                    <%: Html.ValidationMessageFor(m => m.EndDate)%>
                    Content
                    <%: Html.TextBoxFor(x => x.MsgContent, new { @style = "width:350px;" })%>
                    <%: Html.ValidationMessageFor(m => m.MsgContent)%>
                    SrvOpName
                    <%: Html.TextBoxFor(x => x.SrvOpName, new { @style = "width:200px;" })%>
                    <br />
                    <%: Html.RadioButtonFor(x => x.MsgType, 0, new { @Checked = true })%>
                    All
                    <%: Html.RadioButtonFor(x => x.MsgType, 1)%>
                    Only Request
                    <%: Html.RadioButtonFor(x => x.MsgType, 2)%>
                    Only Response
                    <br />
                    <%: Html.RadioButtonFor(x => x.IsHistory, 0, new { @Checked = true })%>Today & Yesterday
                    <%: Html.RadioButtonFor(x => x.IsHistory, 1)%>Long long ago
                </div>
                <p>
                    <input type="submit" value="Search" />
                    <%: Html.ActionLink("Clear All", "Index")%>
                </p>
            </div>
        </fieldset>
    </div>
    <% }
       if (ViewData["CurrentPage"] != null)
       {
    %>
    <h2>
        <%: ViewData["CurrentPage"]%>
        /
        <%: ViewData["TotalPage"]%>
        <%
int currentPage = int.Parse(ViewData["CurrentPage"].ToString());
int previousPage = currentPage > 1 ? currentPage - 1 : 1;
int totalPage = int.Parse(ViewData["TotalPage"].ToString());
int nextPage = currentPage < totalPage ? currentPage + 1 : totalPage;
var rvd = (ViewData["RVD"] as RouteValueDictionary);
rvd.Add("pn", previousPage);
            
        %>
        <%: Html.ActionLink("Previous", "Index", rvd)%>
        <% rvd["pn"] = nextPage; %>
        <%: Html.ActionLink("Next", "Index", rvd)%>
    </h2>
    <table>
        <tr>
            <th>
                Id
            </th>
            <th>
                LogDateTime
            </th>
            <th>
                MsgType
            </th>
            <th>
                SenderID
            </th>
            <th>
                ReceiverID
            </th>
            <th>
                SrvOpName
            </th>
            <th>
                MsgID
            </th>
            <th>
                CorrID
            </th>
            <th>
                Status
            </th>
            <th>
                Action
            </th>
        </tr>
        <% foreach (var item in ViewData["QueryResult"] as IEnumerable<EAILogWebSite.Models.LogEntity>)
           { %>
        <tr>
            <td>
                <%: item.Id%>
            </td>
            <td>
                <%: String.Format("{0:yyyy/MM/dd HH:mm:ss}", item.LogDateTime)%>
            </td>
            <td>
                <%: item.MsgType%>
            </td>
            <td>
                <%: item.SenderID%>
            </td>
            <td>
                <%: item.ReceiverID%>
            </td>
            <td>
                <%: item.SrvOpName%>
            </td>
            <td>
                <%: item.MsgID%>
            </td>
            <td>
                <%: Html.ActionLink(item.CorrID, "Index", new { corrid = item.CorrID })%>
            </td>
            <td>
                <%: item.ESBRspCode == "0" ? "Success" : "Error"%>
            </td>
            <td>
                <%: Html.ActionLink("Detail", "Detail", new { id = item.Id }, new { @target = "_blank" })%>
            </td>
        </tr>
        <% } %>
    </table>
    <%} %>
</asp:Content>
